<#import "/macro.ftl" as m>
<@m.page_header title='推广类别' />
<div id="page-content-wrapper">
    <div id="page-title">
        <h3>推广类别</h3>
        <div id="breadcrumb-right">
            <div class="float-right">
                <a href="/popularizecategorys/add" class="btn medium primary-bg" onclick="showAddPapularizeCatogory();">
                    <span class="button-content">添加</span>
                </a>
            </div>
        </div>
    </div>
    <div id="page-content">
    	<form id="form" action="/popularizecategorys" method="get">
    		<div class="form-row">
    			<div class="form-input col-md-6">
    				<input placeholder="推广类别名称查询" type="text" name="name" id="name" value="${name}">
    			</div>
    			<div class="form-input col-md-2">
		        	<a href="javascript:;" class="btn large primary-bg radius-all-4" id="search" title="Validate!" onclick="$('#form').trigger('submit');">
			            <span class="button-content">
			                查询
			            </span>
	                </a>
		        </div>
    		</div>
    	</form>
    	<table class="table">
	        <thead>
	            <tr>
	                <th>名称</th>
	                <th>稍大类别</th>
	                <th>是否停止推广</th>
	                <th>操作</th>
	            </tr>
	        </thead>
	        <tbody>
	        	<#list categorys.list as category>
					<tr id="${category.id}">
		                <td>${category.name}</td>
		                <td>
		                	<#if category.bigger??>
		                		${category.bigger.name}
		                	</#if>
		                </td>
		                <td>${category.isStopPopularize?string('是', '否')}</td>
		                <td>
		                	<a href="/channels/analyse?<#if category.bigger??>categoryId=${category.id}<#else>biggerCategoryId=${category.id}</#if>" class="btn medium primary-bg">
		                    	<span class="button-content">分析</span>
		                    </a>
		                    <a href="/popularizecategorys/edit/${category.id}" class="btn medium primary-bg">
		                    	<span class="button-content">编辑</span>
		                    </a>
		                    <a href="#" class="btn medium primary-bg" onclick="showDelete(${category.id});">
		                    	<span class="button-content">删除</span>
		                    </a>
		                </td>
		            </tr>
				</#list>    
	    	</tbody>
	    </table>
	    <div class="button-group center-div">
	    	${pagerHelper.content}
	    </div>
    </div>
</div>
<script>

function showDelete( id ){
	$.messager.confirm( "提示", "确定删除推广类别吗？", function(){
		$.post( '/popularizecategorys/delete/' + id )
	     .done(function(data){
	     	if(data["status"] == "success"){
	     		$.jGrowl("删除推广类别成功", {sticky:!1,position:"top-right",theme:"bg-green"});
	     		$('.table').find('tr[id=' + id + ']').remove();
	     	}else{
	     		$.jGrowl(data["message"], {sticky:!1,position:"top-right",theme:"bg-red"});
	     	}
	     })
	     .fail(function(){
	     	$.jGrowl("删除推广类别失败", {sticky:!1,position:"top-right",theme:"bg-red"});
	     });
	});
};

</script>